package com.lanyam.travel.base.service.impl;


import com.lanyam.travel.base.entity.GoodsInfo;
import com.lanyam.travel.base.entity.vo.GoodsInfoVo;
import com.lanyam.travel.base.entity.vo.ScenicHotelVo;
import com.lanyam.travel.base.dao.GoodsInfoMapper;
import com.lanyam.travel.base.service.IGoodsInfoService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;


@Service
@Transactional
@Slf4j
public class GoodsInfoServiceImpl implements IGoodsInfoService {

    @Resource
    private GoodsInfoMapper goodsInfoMapper;

    @Override
    public IPage<GoodsInfoVo> getPageGoodsInfo (Map<String, Object> queryMap, Integer page, Integer rows) {
        Page<GoodsInfoVo> pageSize = new Page<GoodsInfoVo>(page, rows);
        Page<GoodsInfoVo> pageInfo = goodsInfoMapper.getPage(pageSize, queryMap);
        return pageInfo;
    }

    @Override
    public void addGoodsInfo(GoodsInfo goodsInfo) {
        goodsInfoMapper.insert(goodsInfo);
    }

    @Override
    public void updateGoodsInfo(GoodsInfo goodsInfo) {
        goodsInfoMapper.updateById(goodsInfo);
    }

    @Override
    public void delById(String id) {
        goodsInfoMapper.delById(id);
    }

	@Override
	public void deleteByProductId(String productId) {
		// TODO Auto-generated method stub
		QueryWrapper<GoodsInfo> wrapper = new QueryWrapper<GoodsInfo>();
		wrapper.eq("sht_id", productId);
		goodsInfoMapper.delete(wrapper);
	}

	@Override
	public List<GoodsInfo> getGoodsInfoByProductId(String productId) {
		// TODO Auto-generated method stub
		QueryWrapper<GoodsInfo> wrapper = new QueryWrapper<GoodsInfo>();
		wrapper.eq("sht_id", productId);
		List<GoodsInfo> selectList = goodsInfoMapper.selectList(wrapper);
		return selectList;
	}

	@Override
	public GoodsInfo getGoodsInfoById(String goodsInfoId) {
		// TODO Auto-generated method stub
		return goodsInfoMapper.selectById(goodsInfoId);
	}

	@Override
	public List<GoodsInfo> getAllGoodsInfo() {
		// TODO Auto-generated method stub
		return goodsInfoMapper.selectList(null);
	}
}